package cn.edu.dlnu.web.controller;

import cn.edu.dlnu.entity.Question;
import cn.edu.dlnu.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class QuestionController {

    @Autowired
    private QuestionService questionService;

    @RequestMapping("/select/one")
    public void selectOne(){
        String id = "q10001";

        Question question = questionService.findById(id);

        System.out.println(question);
    }

    @RequestMapping("/select/list")
    public void selectList(){
        List<Question> questions = questionService.findAll();

        for (Question question : questions) {
            System.out.println(question);
        }
    }

    @RequestMapping("/question/list")
    public List<Question> list(){
        List<Question> questions = questionService.findQuestionsByTime();

        for (Question question : questions) {
            System.out.println(question);
        }

        return questions;
    }
}
